﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports Contracts
Imports Entities

Public Class GetBorrowerRaiseException
  Inherits Albatross.ServerSide.Messaging.RequestHandler(Of GetBorrowerRaisesExceptionI)

  Public Overloads Overrides Function Handle(ByVal request As GetBorrowerRaisesExceptionI) As Albatross.Common.Messaging.Response
    Dim response As GetBorrowerRaisesExceptionO

    Dim i As Integer = 0
    Dim j As Integer = 1
    Dim k As Integer = j / i ' here we divide by zero, which raises an unhandled exception

    response = New GetBorrowerRaisesExceptionO
    response.MyBorrower = New Borrower()

    Return response
  End Function
End Class

Public Class GetBorrowerRaiseException2
  Inherits Albatross.ServerSide.Messaging.RequestHandler(Of GetBorrowerRaisesException2I)

  Public Overloads Overrides Function OnException(ByVal ex As Exception) As Albatross.Common.Messaging.Response
    Dim response = New GetBorrowerRaisesException2O()

    response.StatusType = -1
    response.ExceptionMessage = ex.Message
    response.MyBorrower = Nothing

    Return response
  End Function

  Public Overloads Overrides Function Handle(ByVal request As GetBorrowerRaisesException2I) As Albatross.Common.Messaging.Response
    Dim response As GetBorrowerRaisesException2O

    Dim i As Integer = 0
    Dim j As Integer = 1
    Dim k As Integer = j / i ' here we divide by zero, which raises an unhandled exception, which should call OnException() above

    response = New GetBorrowerRaisesException2O
    response.MyBorrower = New Borrower()
    response.MyBorrower.FirstName = "Alex"

    Return response
  End Function
End Class

